/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.qdu.servlet;

import com.qdu.entity.PublicActivity;
import com.qdu.service.PublicActivityService;
import com.qdu.service.impl.PublicActivityServiceImpl;


/**
 *
 * @author Daniel
 */


import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/gabis")
public class GetActivityByIdServlet extends HttpServlet {

     PublicActivityService pas = new PublicActivityServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("utf-8");
        //1. 获取请求参数
        //获取提交的活动编号
        int Pno = Integer.parseInt(req.getParameter("Pno"));

        //2. 执行业务逻辑 
        PublicActivity pa = pas.findActivityById(Pno);
        //3. 生成动态响应
        //将查到的对象作为属性放入请求对象，转发请求共享给jsp页面显示信息
        req.setAttribute("pa", pa);
        req.getRequestDispatcher("/Activity_Info.jsp").forward(req, resp);
        
    }
}
